import { isNullOrUndefined } from "util";

export class ModelDevice {
    public id: string;
    public name: string;
    public createdUserId: string;
    public createdUserName: string;
    // 设备类型
    public monitorType: number;
    // 标记点属性信息
    public deviceInfo: gum.IDeviceInfo;
    // 工作集目录id
    public modelLinkId: string;
    public positionInfo: gum.Vector33D;
    public isUpdate = false;
    public monitors: any[];    // monitor关联数组
    public monitorDetails: any[];
    public constructor(param) {
        (!isNullOrUndefined(param.id)) && (this.id = param.id);
        (!isNullOrUndefined(param.name)) && (this.name = param.name);
        (!isNullOrUndefined(param.createdUserId)) && (this.createdUserId = param.createdUserId);
        (!isNullOrUndefined(param.createdUserName)) && (this.createdUserName = param.createdUserName);
        (!isNullOrUndefined(param.monitorType)) && (this.monitorType = param.monitorType);
        (!isNullOrUndefined(param.deviceInfo)) && (this.deviceInfo = param.deviceInfo);
        (!isNullOrUndefined(param.modelLinkId)) && (this.modelLinkId = param.modelLinkId);
        (!isNullOrUndefined(param.positionInfo)) && (this.positionInfo = param.positionInfo);
        (!isNullOrUndefined(param.isUpdate)) && (this.isUpdate = param.isUpdate);
        (!isNullOrUndefined(param.monitorDetails)) && (this.monitorDetails = param.monitorDetails);
    }

    public toJson() {
        return {
            id: this.id,
            name: this.name,
            styleInfo: JSON.stringify(this.deviceInfo),
            modelLinkId: this.modelLinkId,
            createdUserId: this.createdUserId,
            createdUserName: this.createdUserName,
            positionInfo: JSON.stringify(this.positionInfo),
            monitorType: this.monitorType
        };
    }
}
